import { createRouter, createWebHistory } from 'vue-router'
import LoginForm from "@/views/Login/LoginForm";
import TeacherLayout from "@/components/Teacher/TeacherLayout";
import ViewHomework from "@/views/Teacher/ViewHomework";
import PublishHomework from "@/views/Teacher/PublishHomework";
import CreateHomework from "@/views/Teacher/CreateHomework";
import CreateSelect from "@/components/Teacher/CreateSelect";
import CreateEassy from "@/components/Teacher/CreateEassy";
import CreatFill from "@/components/Teacher/CreatFill";
import ViewExperiment from "@/views/Teacher/ViewExperiment";
import PublishExperiment from "@/views/Teacher/PublishExperiment";
import CreateProgram from "@/components/Teacher/CreateProgram";
import HomeworkCharts from "@/views/Teacher/HomeworkCharts";
import StudentLayout from '../components/student/StudentLayout'
import StudentExperiment from "../components/student/StudentExperiment";
import HomeworkDetail from "../components/student/HomeworkDetail";
import registerForm from "@/views/Login/RegisterForm";
import ViewTest from "@/views/Teacher/ViewTest";
import MyExam from "@/components/student/MyExam.vue";
import Test from "@/components/student/Test.vue";
import ClassManage from "@/views/Teacher/ClasssManage";
import PublishTest from "@/views/Teacher/PublishTest";
import CreateTest from "@/views/Teacher/CreateTest";
import ViewHwDetail from "@/views/Teacher/ViewHwDetail";
import ViewStudent from "@/views/Teacher/ViewStudent";


const routes = [
  {
    path: '/Test',
    component: Test,
    props:true
  },
  {
    path: '/MyExam/:currentName/:isSubmitted',
    component: MyExam,
    props:true
  },
  {
    path:'',
    component:LoginForm
  },
  {
    path: '/TeacherLogin',
    component: registerForm
  }
  ,{
    path: '/Teacher',
    component: TeacherLayout,
    children:[
      {
        path:'ViewHomework',
        component: ViewHomework,
      },
      {
        path: 'HomeworkCharts',
        component: HomeworkCharts
      },
      {
        path: 'PublishHomework',
        component: PublishHomework,
      },
      {
        path: 'ViewExperiment',
        component: ViewExperiment,
      },
      {
        path: 'PublishExperiment',
        component: PublishExperiment
      },
      {
        name:'ViewHwDetail',
        path: 'ViewHwDetail/:TaskNum',
        component: ViewHwDetail,
        props($route){
          return {TaskNum:$route.params.TaskNum}
        }
      },
      {
        name:'ViewTest',
        path: 'ViewTest/:studentNum/:TaskNum',
        component: ViewTest,
        props($route){
          return {TaskNum:$route.params.TaskNum,studentNum:$route.params.studentNum}
        }
      },
      {
        name:'ChangeQuests',
        path: 'ChangeQuests/:TaskNum/:type',
        component: ViewTest,
        props($route){
          return {TaskNum:$route.params.TaskNum,type:parseInt($route.params.type)}
        }
      },

      {
        path: 'ClassManage',
        component: ClassManage,
      },
      {
        path:'CreateTest',
        component: CreateTest,
        children:[{
          path:'CreateSelect',
          component:CreateSelect,
        },
          {
            path: 'CreateEssay',
            component: CreateEassy
          }
          ,
          {
            path: 'CreateFill',
            component: CreatFill
          },
          {
            path: 'CreateProgram',
            component: CreateProgram
          }
        ]
      },
      {
        path: 'PublishTest',
        component: PublishTest,
      },
      {
        path: 'ViewTest',
        component: ViewTest,
      },
      {
        path: 'ViewStudent',
        component: ViewStudent,
      },

      {
        path:'CreateHomework',
        component: CreateHomework,
        children:[{
            path:'CreateSelect',
            component:CreateSelect,
        },
        {
            path: 'CreateEssay',
            component: CreateEassy
        }
        ,
        {
            path: 'CreateFill',
            component: CreatFill
        },
        {
            path: 'CreateProgram',
            component: CreateProgram
        }
        ]
      }
    ]
  },
  {
    path:'/StudentLayout',component:StudentLayout,
    children:
        [
          {
            path: 'StudentExperiment/:currentName/:isSubmitted',
            component: StudentExperiment,
            props:true
          }
        ]
  },
  {
    path: '/HomeworkDetail/:currentName/:currentHomework',
    component: HomeworkDetail,
    props:true
  }
]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

export default router
